#ifndef LUASYNTAXHIGHLIGHTER_H
#define LUASYNTAXHIGHLIGHTER_H

#include <QSyntaxHighlighter>
#include <QRegularExpression>

class LuaSyntaxHighlighter final : public QSyntaxHighlighter
{
public:
    explicit LuaSyntaxHighlighter(QTextDocument *parent = nullptr);
    ~LuaSyntaxHighlighter() override;

protected:
    void highlightBlock(const QString &text) override;

private:
    struct HighlightingRule
    {
        QRegularExpression pattern;
        QTextCharFormat format;
    };

    QVector<HighlightingRule> highlighting_rule_rules_;
    QRegularExpression comment_start_expression_;         //多行注释开始标识符
    QRegularExpression comment_end_expression_;           //多行注释结束标识符
    QTextCharFormat keyword_format_;                      //关键字
    QTextCharFormat class_format_;                        //类
    QTextCharFormat single_key_;                          //单行关键字
    QTextCharFormat single_line_value_;                   //单行值
    QTextCharFormat single_line_comment_format_;          //单行注释
    QTextCharFormat multi_line_comm_format_;              //多行注释
    QTextCharFormat quotation_format_;                    //字符串标识符
    QTextCharFormat function_format_;                     //方法标识符
};

#endif //LUASYNTAXHIGHLIGHTER_H
